# -*- coding: utf-8 -*-



import json
import os
import pandas as pd

os.chdir(u'E:\\Work\\Document\\重庆银行\\烟商项目\\数据类\\真实客户评分数据')

f = open(u'邵金琼-烟草.json')

mydata = json.load(f)

mydf = pd.DataFrame(mydata)

mydf_indent = mydf['indent'] #定烟记录

detail_all = pd.DataFrame()
tmpall = pd.DataFrame()
result = pd.DataFrame()


for i in range(0, mydf.shape[0]): #每一次定烟总记录
    tmp = mydf.iloc[i]['indent']
    tmp = pd.DataFrame(tmp)
    ind = 0
    for j in range(0, tmp.shape[0]):
        
        detail = pd.DataFrame(tmp.iloc[j]['indentDetails'],index=[0])
        detail['indentAccount'] = tmp.iloc[j]['indentAccount']
        detail['indentDate'] = tmp.iloc[j]['indentDate']
        detail['indentMoney'] = tmp.iloc[j]['indentMoney']
        detail['indentNum'] = tmp.iloc[j]['indentNum']
        detail['accountNum'] = mydf.iloc[i]['accountNum']
        detail['custSize'] = mydf.iloc[i]['custSize']
        detail['gear'] = mydf.iloc[i]['gear']
        detail['seq'] = ind
        ind = ind +1
        detail_all = pd.concat([detail_all, detail])

detail_all.to_excel(u'邵金琼-烟草.xls')